﻿using System.Windows.Controls;
using GameModels.GameModels;

namespace Controls.Level
{
    /// <summary>
    /// Represents a level terrain.
    /// </summary>
    public class LevelTerrainControl : Canvas
    {
        private const int CellSize = 5;

        public LevelTerrainControl(IGameModel gameModel)
        {
            GameModel = gameModel;
            var size = gameModel.LevelModel.LevelSize;
            Height = size.Height * CellSize;
            Width = size.Height * Width;
        }

        private IGameModel GameModel { get; set; }

        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);
            var level = GameModel.LevelModel;
            for (int i = 0; i != level.LevelSize.Width; ++i)
            {
                for (int j = 0; j != level.LevelSize.Height; ++j)
                {
                    level.Level[i][j].Draw(dc);
                }
            }
        }
    }
}